package classfile

type MemberInfo struct {
	cp              ConstantPool
	accessFlags     uint16          //访问标记
	nameIndex       uint16          //字段索引
	descriptorIndex uint16          //方法索引
	attributes      []AttributeInfo //属性表
}

func readMembers(reader *ClassReader, cp ConstantPool) []*MemberInfo {
	memberCount := reader.readUint16()
	members := make([]*MemberInfo, memberCount)
	for i := range members {
		members[i] = readMember(reader, cp)
	}
	return members
}

func readMember(reader *ClassReader, cp ConstantPool) *MemberInfo {
	return MemberInfo{
		cp: cp,
		accessFlags : reader.readUint16(),
		nameIndex : reader.readUint16(),
		descriptorIndex : reader.readUint16(),
		attributes : readAttributes(reader, cp),
	}

}

func (self *MemberInfo) AccessFlags() uint16 {
	return self.accessFlags
}

func (self *MemberInfo) Name() string {
	return self.cp.getUtf8(self.nameIndex) //根据索引取名字
}

func (self *MemberInfo) Descriptor() string {
	return self.cp.getUtf8(self.descriptorIndex) //根据索引取名字
}


